package piece1.chapter5;

public class Problem5_18 {

    /**
     * @param args
     */
    public static void main(String[] args) {
	// TODO 自动生成的方法存根
	double[][] num = new double[5][5];
	for (int i = 0; i < num.length; i++) {
	    for (int j = 0; j < num[i].length; j++) {
		num[i][j] = Math.random() * 100;
	    }
	}
	MatrixSum(num);

	double[][] test = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 },
		{ 13, 14, 15, 16 } };

	System.out.println((int) MatrixSum(test));
    }

    public static double MatrixSum(double num[][]) {
	double sum = 0;
	for (int i = 0; i < num.length; i++) {
	    for (int j = 0; j < num[i].length; j++) {
		sum += num[i][j];
	    }
	}
	System.out.println(sum);
	return sum;

    }
}
